import {Directive, HostBinding, Input} from '@angular/core';
import {ButtonDirective} from "primeng/button";
import {TableDirective} from "../data/table.directive";

@Directive({
  selector: '[gnTableButtonEdit]',
})
export class TableButtonEditDirective {

  @HostBinding("class") class = 'ui-button-raised ui-button-warning';

  @HostBinding("attr.disabled") get disabled() {
    return this.table.hasSelectedOne ? null : "disabled";
  };

  @Input() table: TableDirective

  constructor(button: ButtonDirective) {
    button.label = '修改';
    button.icon = 'pi pi-pencil';
  }
}
